from typing import TypedDict

from sympy import false


class HumanMessage(TypedDict):
    role: str
    content: str
    is_abandoned: str
class AIMessage(TypedDict):
    role: str
    content: str
    is_abandoned: str
class SystemMessage(TypedDict):
    role: str
    content: str
    is_abandoned: str
class ToolMessage(TypedDict):
    role: str
    content: str
    name: str
    tool_call_id: str
    arguments: str
    # TODO 这个属性不是很好
    is_abandoned: str

def build_human_message(user_message: str, is_abandoned: bool = false) -> HumanMessage:
    return {'role': 'user', 'content': user_message, 'is_abandoned': "true" if is_abandoned else "false"}

def build_ai_message(ai_message: str, is_abandoned: bool = false) -> AIMessage:
    return {'role': 'assistant', 'content': ai_message, 'is_abandoned': "true" if is_abandoned else "false"}

def build_system_message(sys_message: str, is_abandoned: bool = false) -> SystemMessage:
    return {'role': 'system', 'content': sys_message, 'is_abandoned': "true" if is_abandoned else "false"}

def build_tool_message(tool_message: str, tool_call_id='', tool_name='', arguments='', is_abandoned: bool = false) -> ToolMessage:
    return {'role': 'tool', 'name': tool_name, 'content': tool_message, 'tool_call_id': tool_call_id, 'arguments': arguments, 'is_abandoned': "true" if is_abandoned else "false"}

class HistoryLoader:
    # 没有限制历史记录的格式，但必须是一个数组
    def get_history(self) -> list:
        raise NotImplementedError
    # 批量添加历史记录
    def add_messages(self, messages: list):
        raise NotImplementedError